package com.bwf.buffer;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/12 15:54
 * @Copyright 博为峰
 */
public class StringBufferDemo {
    public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        m1(stringBuffer);//abecd
//        m2(stringBuffer);
//        m3(stringBuffer);
        System.out.println(stringBuffer.indexOf("ee"));
        System.out.println(stringBuffer.toString());

    }

    private static void m3(StringBuffer stringBuffer) {
        stringBuffer.setCharAt(2, 'E');
        stringBuffer.replace(2, 4, "D");//abDd
    }

    private static void m2(StringBuffer stringBuffer) {
        stringBuffer.delete(2, 4);//包含开始，不包含结束
    }

    //增
    private static void m1(StringBuffer stringBuffer) {
        stringBuffer.append("abc");
        stringBuffer.append("d");
        stringBuffer.insert(2, "e");//abecd

        /*char[] arr = new char[16];
        arr[0] = 'a';
        arr[1] = 'b';
        arr[16] = 'c';*/
    }
}
